package com.bops.dal.information.dao.impl;

import java.util.List;

import com.bops.dal.information.dao.NewsInfoDAO;
import com.bops.dal.information.dataobject.NewsInfoDO;
import com.bops.dal.information.queryobject.NewsInfoQuery;
import com.yue.commons.db.ibatis.YueBaseSqlMapClientDaoSupport;

public class NewsInfoDAOImpl  extends YueBaseSqlMapClientDaoSupport implements NewsInfoDAO{

	private static final String NAME_SPACE = "NEWS_NEWS.";
	
	public Integer insert(NewsInfoDO newsDO) {
		return (Integer) getSqlMapClientTemplate().insert(NAME_SPACE + "insert", newsDO);
	}

	public boolean update(NewsInfoDO newsDO) {
		return getSqlMapClientTemplate().update(NAME_SPACE + "update", newsDO) > 0;
	}

	public NewsInfoDO getById(Integer id) {
		return (NewsInfoDO) getSqlMapClientTemplate().queryForObject(NAME_SPACE + "listById", id);
	}

    @SuppressWarnings("unchecked")
	public List<NewsInfoDO> listNews(NewsInfoQuery query) {
    	if (query==null)
        {
            query = new NewsInfoQuery();
            query.setPageSize(Integer.MAX_VALUE);
        }
		return getSqlMapClientTemplate().queryForPagination(NAME_SPACE + "count_news", NAME_SPACE + "list_news", query);
	}

	public boolean delete(Integer id) {
		return getSqlMapClientTemplate().delete(NAME_SPACE + "delete", id) > 0;
	}


}
